<%@page import="com.charlie.beans.Groups"%>
<%@page import="java.util.List"%>

<%@include file="/header.jsp"%>

<%
    List<Groups> groups = (List<Groups>) request.getAttribute("groupsList");
    List<String> roles = (List<String>) request.getAttribute("groupRoles");
%>

<div class="left_side">
    <jsp:include page="/blocks/conditionalLeftBar.jsp" />
</div>

<div class="right_side">
    <h2 class="content_title">Groups: </h2>
    <div class="white_block" overflow="scroll">
        <h2 style="text-align: center;">List of groups: </h2>
        <table class="typycal_table">
            <thead>   
                <tr>
                    <th>GROUP NAME</th>
                    <th>ROLES</th>
                </tr>
            </thead>
            <tbody>
                <%if (groups != null) {
                        if (groups.size() == roles.size()) {
                            for (int i = 0; i < roles.size(); i++) {

                %>
                <tr>
                    <td><%=groups.get(i).getName()%> </td>
                    <td><%=roles.get(i)%></td>
                    <td>
                        <form method="post" action="editGroup?groupId=<%=groups.get(i).getGroupsId()%>">
                            <input type="submit" value="Edit" name="edit" />
                        </form>
                    </td>
                    <td>
                        <form method="post" class="disable_on_ckick" action="deleteGroup?groupId=<%=groups.get(i).getGroupsId()%>">
                            <input type="submit" value="Delete" name="delete" />
                        </form>
                    </td>
                    <td>
                        <form method="post" action="groupDeleteUser?groupId=<%=groups.get(i).getGroupsId()%>">
                            <input type="submit" value="Members" name="members" />
                        </form>
                    </td>
                </tr>
                <%}
                        }
                    }%>
            </tbody>
        </table>
    </div>  
    <jsp:include page="/blocks/pages.jsp">
        <jsp:param name="path" value="/admin/groups" />
    </jsp:include>
</div>
<%@include file="/footer.jsp" %>